Conversation
When submitting a prompt, the previous code expanded `[Pasted ~N lines]`
placeholders into their original content using the extmark's `start`/
`end` offsets:
inputText.slice(0, extmark.start) + part.text + inputText.slice(extmark.end)
If the user pasted text and then moved the cursor to type characters
*before* the placeholder, the extmark's offsets in the underlying
input buffer drifted relative to `inputText`. The slice then took the
wrong range, leaving fragments of the placeholder string (for example
"d ~1 lines]") inside the submitted message.
Replace the offset-based slice with a `lastIndexOf` lookup of the
stored virtual text (`part.source.text.value`), iterating extmarks
right-to-left so duplicate placeholders are still paired correctly.
This eliminates dependence on opentui's offset tracking after edits.
The github-copilot direct-login path in quota-fetch.ts was sending `token <refresh>` as the Authorization header when calling /copilot_internal/user. However, the copilot plugin itself consistently uses `Bearer <refresh>` for all GitHub API calls (copilot.ts:72,154). The /copilot_internal/user endpoint rejects the `token` prefix format, returning 401, which caused fetchQuota to silently return null and the quota indicator to never display for direct OAuth users. Change authHeaderPrefix from "token" to "Bearer" so it matches the copilot plugin's auth format. This fixes the issue where github-proxy users could see their quota but github-copilot direct-login users could not.
- parseCopilotQuota 改用 snake_case 字段(quota_snapshots / premium_interactions / remaining / entitlement),修复 GitHub API 响应解析全部返回 null 的问题 - readQuotaAuth → readQuotaAuths 返回 QuotaAuth[],同时收集 github-proxy 与 github-copilot 两条来源 - fetchQuota 接收数组,依次尝试,proxy 不可达时自动降级到 copilot - 测试同步更新,新增 fallback 降级用例,共 22 个全部通过
已知 opencode issue #8030:合成 user 消息(compaction / subtask / 图片附件) 被 copilot.ts loader.fetch 错判为 user 请求,导致每轮 agentic 循环均扣 premium quota。本提交在 fetch 出站前记录 xInitiator、hookHeader、 isAgent、lastRole、lastContentTypes、lastTextSample 供分析。 用完即删,正式修复见后续提交。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
彻底解决计费问题